<script setup>
import { ref } from 'vue'
import Home from './components/home.vue'
import Car from './components/car/index.vue'
import VScaleScreen from 'v-scale-screen'
import { useWindowSize } from '@vueuse/core'

const { width } = useWindowSize()
const curTab = ref('home')

const containerRef = ref(null)
// 显示主页
const showHome = () => {
  containerRef.value.scrollLeft = 0
  curTab.value = 'home'
}
// 显示车辆信息
const showCar = () => {
  containerRef.value.scrollLeft = width.value * 10
  curTab.value = 'car'
}
</script>
<template>
  <v-scale-screen fullScreen>
    <div class="index-wrapper">
      <div class="header">
        <img class="logo" src="@/assets/park-logo.png" alt="" ref="logo" />
        <div class="btn-list">
          <div v-if="curTab === 'home'" ref="btn1">
            <img src="@/assets/park-active.png" alt="" @click="showHome" />
          </div>
          <div v-else ref="btn2">
            <img src="@/assets/park-default.png" alt="" @click="showHome" />
          </div>
          <div v-if="curTab === 'car'" ref="btn3">
            <img src="@/assets/car-active.png" alt="" @click="showCar" />
          </div>
          <div v-else ref="btn4">
            <img src="@/assets/car-default.png" alt="" @click="showCar" />
          </div>
        </div>
      </div>
      <div class="page-container" ref="containerRef">
        <home ref="homeRef" id="home" />
        <car ref="carRef" id="car" />
      </div>
    </div>
  </v-scale-screen>
</template>
<style lang="scss" scoped>
.index-wrapper {
  position: relative;
  height: 100%;
  background-color: black;
  .header {
    position: fixed;
    top: 0;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    width: 100%;
    margin-bottom: 30px;
    z-index: 10;
    .logo {
      width: 460px;
    }
    .btn-list {
      display: flex;
      img {
        width: 96px;
        margin-right: 24px;
        cursor: pointer;
      }
    }
  }
  .page-container {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: row;
    scroll-behavior: smooth;
  }
}
</style>
